<?php

class Adept_ClassKit_Delegate_List 
{

    /**
     * 
     * @param list
     * @param args
     */
    public static function invokeAll($list, $args) 
    {
            if (is_array($list)) {
                foreach ($list as $delegate) {
                    $delegate->invoke($args);
                }
            } 
            elseif (is_object($list)) {
                return $list->invoke($args);
            }
    }

    /**
     * 
     * @param list
     * @param args
     */
    public static function invokeChain($list, $args) 
    {
        if (is_array($list)) {
            foreach ($list as $delegate) {
                $result = $delegate->invoke($args);
                if ($result != null) {
                    return $result;
                }
            }
        return null;
        } elseif (is_object($list)) {
            return $list->invoke($args);
        }
    }

}
